const d_ordinary = {
    name:'D_ordinary',
    template: `<div class="wh100 ovy imgmw justify">
        <div class="bodypd w100">
            <div class="title ff1 fsw7 sp_1 lh30 pdb5" v-text="ob.name"></div>
            <div class="ff1 mask2 fs075e">作者：<span class="disi pdtb5">吹风机</span></div>
            <div class="ff1 mask0 fs075e ">更新于 <span class="disi" v-text="ob.update_time"></span></div>
            <div class="line1"></div>

            <div name="content" class="content cont" v-html="ob.content"></div>
            <div class="h50"></div>
            <div class="w100 flex textc jusa ff1 lh20">
                <div href="" class="a-item disn" @click="weixinSendAppMessage()">
                	<el-button type="warning" round class="el-button w80 h30 flec center sp1 ">立即分享</el-button>
                </div>
                <div v-if="a" class="a-item"  @click="backOne()">
                	<el-button type="warning" round class="el-button w80 h30 flec center sp1 ">上一页</el-button>
                </div>
                <a :href="hrefA+'/'" class="a-item">
                	<el-button type="warning" round class="el-button w80 h30 flec center sp1 bgcof ">返回首页
                	</el-button>
                </a>
            </div>
            <div class="h30"></div>
        </div>
        <div class="w100 textc bg bdt1 bbx pdtb10 ff1 cont">
            <span class="disb sp2">深圳百岁元健康发展有限公司</span>
            <span class="disb  h5"></span>
            <span class="disb fs09e sp1 a">备案号：*******</span>
        </div>
    </div>`,
    data: function () { return{
        ob:{},
        a:0,
        hrefA:hrefA

    } },
    created() {
        let v=this;
        v.getList()
    },
    mounted(){
    	let v = this;
    	
    	// v.setWx();
    },
    methods: {
    	getWxConfig(info){
    		let v = this;
    		console.log('getWxConfig');
    		let uri = '/api/weixin/jsapi_sign';
    		ajax({url:uri,method:'get'}).then((r)=>{
                if(r.code == 200){
                    console.log('wx_config',r.data);
                    if(r.data.appId) {
                    	v.setWx(r.data,info);
                    }
                }
            }).catch((e)=>{
                console.log('catch getWxConfig',e);
            })
    	},
    	getShareLink(){
    		let v = this;
    		let uri = '/api/share/article';
    		let id = v.$route.query.id || v.$route.query.banner_id || v.$route.query.column_id;
    		let token = localStorage.token;
    		if(!token) {
    			console.log('!token return');
    			return;
    		}
    		ajax({url:uri,method:'get',data:{id:id,token:token}}).then((r)=>{
                if(r.code == 200){
                    console.log('getShareLink',r.data);
                    v.getWxConfig(r.data);
                }
            }).catch((e)=>{
                console.log('catch',e);
            })
    	},
    	setWx(d,info){
    		let v = this;
    		let jsapi = ['updateAppMessageShareData','updateTimelineShareData'];
    		let opt = {
	    		debug: false, 
				appId: d.appId, 
				timestamp: d.timestamp, 
				nonceStr: d.nonceStr, 
				signature: d.signature,
				jsApiList: jsapi //[] 
			}
    		console.log('wx.config()',opt,info);
			wx.config(opt);
			wx.checkJsApi({
				jsApiList: jsapi, // 需要检测的JS接口列表，所有JS接口列表见附录2,
				success: function(r) {
					console.log('checkJsApi success'.r)
				},
				complete: function(r) {
					console.log('checkJsApi complete'.r)
				},
			});
			wx.ready(function () {
				wx.updateAppMessageShareData({ 
				    title: info.title || v.ob.name || '分享标题', // 分享标题
				    desc: info.description || v.ob.description || '分享描述', // 分享描述
				    link: info.url || location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				    imgUrl: info.img || '', // 分享图标
				    success: function (r) {
				      console.log('updateAppMessageShareData',r)
				    }
				})
				// 自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容（1.4.0
				wx.updateTimelineShareData({
					title: info.title || '分享标题', // 分享标题
				    desc: info.description || '分享描述', // 分享描述
				    link: info.url || location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				    imgUrl: info.img || '', // 分享图标
					success: function (r) {
						console.log('updateTimelineShareData',r)
					}
				})
				wx.onMenuShareAppMessage({
					title: 'title', // 分享标题
					desc: 'desc', // 分享描述
					link: location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: '', // 分享图标
					type: '', // 分享类型,music、video或link，不填默认为link
					dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
					success: function () {
				    	console.log('onMenuShareAppMessage')
					}
				});
			});
			wx.error(function(r){
				console.log('wx.error',r)
			});
			console.log('wx.config << ')
    	},
    	weixinSendAppMessage(title,desc,link,imgUrl){
    		console.log('weixinSendAppMessage')
    		WeixinJSBridge.on('menu:share:appmessage', function(argv){
    			console.log('WeixinJSBridge')
		        WeixinJSBridge.invoke('sendAppMessage',
			        {
			            "appid":"", //appid 设置空就好了。
			            "img_url": '', //分享时所带的图片路径
			            "img_width": "120", //图片宽度
			            "img_height": "120", //图片高度
			            "link":location.href, //分享附带链接地址
			            "desc":"我是一个介绍", //分享内容介绍
			            "title":"标题，再简单不过了。"
			        }, 
		        	function(res){}
		       );
		   });
		},
        backOne(){
            let v= this
            v.$router.go(-1)
        },
        getList(){
            let v= this
            let uri = '/api/article/info'
            if(v.$route.query.a)v.a = v.$route.query.a
            let id = v.$route.query.id || v.$route.query.banner_id || v.$route.query.column_id
            ajax({url:uri,method:'get',data:{id:id}}).then((r)=>{
                if(r.code == 200){
                    console.log('article_info',r.data);
                    v.ob = r.data;
                    v.getShareLink();
                    // v.getWxConfig();
                }
            }).catch((e)=>{
                console.log('catch',e);
            })
        }
    },
}
export default d_ordinary